package pikes.peak;

import java.util.Collections;
import java.util.Map;

import org.springframework.web.servlet.support.RequestContext;

import pikes.uri.RelativeURI;
import pikes.uri.URI;

public class SelfURI implements RequestProperty<URI> {

	private RequestProperty<Map<CharSequence, CharSequence>> parameters = new RequestIndependentProperty<Map<CharSequence, CharSequence>>(
			Collections.EMPTY_MAP);

	public SelfURI() {
		super();
	}

	public SelfURI(final Map<CharSequence, CharSequence> parameters) {
		this(new RequestIndependentProperty<Map<CharSequence, CharSequence>>(parameters));
	}

	public SelfURI(final RequestProperty<Map<CharSequence, CharSequence>> parameters) {
		this.parameters = parameters;
	}

	public final URI getValue(Map model, RequestContext requestContext) throws Exception {
		return new RelativeURI(requestContext.getRequestUri(), parameters.getValue(model, requestContext));
	}

}
